package netty.rpc.core;

import javafx.util.Pair;

import java.io.Serializable;
import java.util.*;

/**
 * 服务暴露的接口描述
 * @author Jim
 * @version 1.0.0
 * @descripition:
 * @date 2022/5/21 14:37
 */
public class InterfaceDefinition implements Serializable {

    private static final long serialVersionUID = -3244668726150551738L;

    //TODO interfaceId 接口维度的灰度，流量平衡

    /**
     * 服务名
     */
    private String interfaceName;

    /**
     * 方法定义
     */
    private List<MethodDefinition> methodDefinitionList = new ArrayList<>();

    /**
     * 接口是否启用
     */
    private boolean interfaceEnabled;



    /**
     * 接口超时时间
     * @return
     */
    long timeOut;

    /**
     * ===========================================         ==============================================
     * ====================================== 后续版本待实现功能 ==============================================
     * ===========================================         ==============================================
     */

    /**
     * 是否开启重试
     * @return
     */
    boolean enableRetry;

    /**
     * 失败重试次数
     * @return
     */
    int retryTimes;

    /**
     * 重试间隔
     * @return
     */
    long retryInterval;

    /**
     * 是否开启方法指标统计
     * @return
     */
    boolean enableMethodIndexMetrics;


    /**
     * 是否开启接口指标统计
     * @return
     */
    boolean enableInterfaceIndexMetric;





    public boolean isEnableRetry() {
        return enableRetry;
    }

    public void setEnableRetry(boolean enableRetry) {
        this.enableRetry = enableRetry;
    }

    public long getTimeOut() {
        return timeOut;
    }

    public void setTimeOut(long timeOut) {
        this.timeOut = timeOut;
    }

    public int getRetryTimes() {
        return retryTimes;
    }

    public void setRetryTimes(int retryTimes) {
        this.retryTimes = retryTimes;
    }

    public long getRetryInterval() {
        return retryInterval;
    }

    public void setRetryInterval(long retryInterval) {
        this.retryInterval = retryInterval;
    }

    public boolean isEnableMethodIndexMetrics() {
        return enableMethodIndexMetrics;
    }

    public void setEnableMethodIndexMetrics(boolean enableMethodIndexMetrics) {
        this.enableMethodIndexMetrics = enableMethodIndexMetrics;
    }

    public boolean isEnableInterfaceIndexMetric() {
        return enableInterfaceIndexMetric;
    }

    public void setEnableInterfaceIndexMetric(boolean enableInterfaceIndexMetric) {
        this.enableInterfaceIndexMetric = enableInterfaceIndexMetric;
    }



    public String getInterfaceName() {
        return interfaceName;
    }

    public void setInterfaceName(String interfaceName) {
        this.interfaceName = interfaceName;
    }

    public List<MethodDefinition> getMethodDefinitionList() {
        return methodDefinitionList;
    }

    public void setMethodDefinitionList(List<MethodDefinition> methodDefinitionList) {
        this.methodDefinitionList = methodDefinitionList;
    }

    public boolean isInterfaceEnabled() {
        return interfaceEnabled;
    }

    public void setInterfaceEnabled(boolean interfaceEnabled) {
        this.interfaceEnabled = interfaceEnabled;
    }

    @Override
    public String toString() {
        return "InterfaceDefinition{" +
                "interfaceName='" + interfaceName + '\'' +
                ", methodDefinitionList=" + methodDefinitionList +
                ", interfaceEnabled=" + interfaceEnabled +
                ", timeOut=" + timeOut +
                ", enableRetry=" + enableRetry +
                ", retryTimes=" + retryTimes +
                ", retryInterval=" + retryInterval +
                ", enableMethodIndexMetrics=" + enableMethodIndexMetrics +
                ", enableInterfaceIndexMetric=" + enableInterfaceIndexMetric +
                '}';
    }
}
